 package handling.cashshop.handler;

 import client.MapleClient;
 import client.inventory.Equip;
 import client.inventory.Item;
 import client.inventory.MapleInventoryType;
 import configs.MTSConfig;
 import configs.ServerConfig;
 import constants.ItemConstants;
 import constants.ServerConstants;
 import database.DatabaseConnection;
 import handling.opcode.MtsOpcode;
 import java.sql.Date;
 import java.sql.PreparedStatement;
 import java.sql.SQLException;
 import java.text.SimpleDateFormat;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import server.MTSItemsInfo;
 import server.MapleInventoryManipulator;
 import tools.StringUtil;
 import tools.data.input.LittleEndianAccessor;
 import tools.packet.MTSPacket;


 public class MTSOperation
 {
/*  28 */   private static final Logger log = LogManager.getLogger(MTSOperation.class); public static void newMTSOperation(LittleEndianAccessor slea, MapleClient c) { MTSItemsInfo mts; int ItemID; byte unk; int ItemNum, state; long Price; String ItemName, ItemName2; int hour, mod_1; byte ItemType; int mod_2, slot, level_1, cash, level_2; MapleInventoryType types;
     long price_1;
     Item item;
     long price_2;
     int unk_1;
     byte unk_2;
/*  34 */     int unk_3, type = slea.readInt();
/*  35 */     MtsOpcode mode = MtsOpcode.getByAction(type);
/*  36 */     if (c.getPlayer() == null || mode == null) {
/*  37 */       if (ServerConstants.isShowPacket()) {
/*  38 */         System.out.println("拍卖未知的操作类型: 0x" + StringUtil.getLeftPaddedStr(Integer.toHexString(type).toUpperCase(), '0', 2) + " " + slea.toString());
       }
/*  40 */       c.getPlayer().sendEnableActions();
       return;
     }
/*  43 */     MTSItemsInfo MtsOperation = MTSItemsInfo.getInstance();
/*  44 */     switch (mode) {

       case 进入拍卖:
/*  47 */         c.announce(MTSPacket.AuctionMessage(type));
/*  48 */         mts = MTSItemsInfo.getInstance();

/*  50 */         loadQuotationInfo(c, mts);

/*  52 */         loadListInfo(c, mts);
         break;




       case 离开拍卖:
/*  59 */         CashShopOperation.LeaveCS(slea, c, c.getPlayer(), false);
         break;

       case 上架道具:
/*  63 */         if (MTSConfig.MTS_SELL_TIME > 0) {
/*  64 */           String mtsselltime = c.getPlayer().getKeyValue("MTS_SELL_TIME");

/*  66 */           if (mtsselltime != null) {
/*  67 */             long diff = System.currentTimeMillis() - Long.parseLong(mtsselltime);

/*  69 */             long minute = diff / 60L / 1000L;
/*  70 */             if (minute < MTSConfig.MTS_SELL_TIME) {
/*  71 */               c.getPlayer().dropMessage(1, "为了服务器稳定 " + MTSConfig.MTS_SELL_TIME + "分钟后才能上架物品 上次操作时间为:" + stampToDate(mtsselltime));
               return;
             }
           }
/*  75 */           c.getPlayer().setKeyValue("MTS_SELL_TIME", System.currentTimeMillis() + "");
         }

/*  78 */         slea.readInt();
/*  79 */         ItemID = slea.readInt();
/*  80 */         ItemNum = slea.readInt();
/*  81 */         Price = slea.readLong();
/*  82 */         hour = slea.readInt();
/*  83 */         ItemType = slea.readByte();
/*  84 */         slot = slea.readInt();
/*  85 */         cash = slea.readInt();

/*  87 */         if (c.getPlayer().getMeso() < 2000L) {
/*  88 */           c.getPlayer().dropMessage(1, "金币不足。");
           return;
         }
/*  91 */         if (ItemNum < 0) {

/*  93 */           c.getPlayer().dropMessage(1, "上架数量异常");
           return;
         }
/*  96 */         types = ItemConstants.getInventoryType(ItemID);
/*  97 */         if (c.getPlayer().getInventory(types).getItem((short)slot) == null) {
           return;
         }

/* 101 */         item = c.getPlayer().getInventory(types).getItem((short)slot).copy();
/* 102 */         if (item.getType() == 1) {
/* 103 */           Equip equip = (Equip)item;
/* 104 */           if (equip.getFire() > 0L) {
/* 105 */             c.getPlayer().dropMessage(1, "暂时无法上架火花装备");

             return;
           }
         }

/* 111 */         if (item.getItemId() == ItemID && item.getQuantity() >= ItemNum) {

/* 113 */           c.getPlayer().gainMeso(-2000L, false);
/* 114 */           MapleInventoryManipulator.removeFromSlot(c, types, item.getPosition(), (short)ItemNum, false);

/* 116 */           long start = System.currentTimeMillis();

/* 118 */           int day = 1;

/* 120 */           AuctionSave(c, item, ItemNum, ItemType, Price, ItemNum * Price, c.getPlayer().getId(), c.getPlayer().getName(), 0, "", start, start + (86400000 * day), -1L);


/* 123 */           loadSellInfo(c, MtsOperation);











/* 135 */           log.info("[上架物品] 玩家:" + c.getPlayer().getName() + " 道具:" + ItemID + " 数量:" + ItemNum + " 价格:" + Price);
         }
         break;

       case 重新上架:
/* 140 */         if (MTSConfig.MTS_AGAIN_SELL_TIME > 0) {
/* 141 */           String mtsselltime = c.getPlayer().getKeyValue("MTS_AGAIN_SELL_TIME");

/* 143 */           if (mtsselltime != null) {
/* 144 */             long diff = System.currentTimeMillis() - Long.parseLong(mtsselltime);

/* 146 */             long minute = diff / 60L / 1000L;
/* 147 */             if (minute < MTSConfig.MTS_AGAIN_SELL_TIME) {
/* 148 */               c.getPlayer().dropMessage(1, "为了服务器稳定 " + MTSConfig.MTS_AGAIN_SELL_TIME + "分钟后才能重新上架物品 上次操作时间为:" + stampToDate(mtsselltime));

               return;
             }
           }
/* 153 */           c.getPlayer().setKeyValue("MTS_AGAIN_SELL_TIME", System.currentTimeMillis() + "");
         }


         try {
/* 158 */           int invid = slea.readInt();
/* 159 */           int i = slea.readInt();
/* 160 */           int sell_invid = slea.readInt();
/* 161 */           int accid = slea.readInt();
/* 162 */           int cid = slea.readInt();
/* 163 */           int itemid = slea.readInt();
/* 164 */           int j = slea.readInt();
/* 165 */           long price = slea.readLong();
/* 166 */           long donetinme = slea.readLong();
/* 167 */           long l1 = slea.readLong();
/* 168 */           int result = slea.readInt();
/* 169 */           int k = slea.readInt();
/* 170 */           int m = slea.readInt();


/* 173 */           MTSItemsInfo mtsdoneitem = MtsOperation.getDoneItemsingleNum(c, invid);
/* 174 */           if (mtsdoneitem == null) {
/* 175 */             c.getPlayer().dropMessage(1, "道具不存在.请尝试退出拍卖在进入。");

             return;
           }
/* 179 */           if (c.getPlayer().getMeso() < 2000L) {
/* 180 */             c.getPlayer().dropMessage(1, "金币不足。");

             return;
           }

/* 185 */           c.getPlayer().gainMeso(-2000L, false);

/* 187 */           mtsdoneitem.UpdateItemState(invid, 9);

/* 189 */           long start = System.currentTimeMillis();

/* 191 */           int day = 1;

/* 193 */           AuctionSave(c, mtsdoneitem.getSpItem(), mtsdoneitem.getQuantity(), mtsdoneitem.getType(), mtsdoneitem.getPrice(), mtsdoneitem.getTotalPrice(), c.getPlayer().getId(), c.getPlayer().getName(), 0, "", start, start + (86400000 * day), -1L);

/* 195 */           c.announce(MTSPacket.AuctionMessage(type));

/* 197 */           loadSellInfo(c, MtsOperation);

/* 199 */           loadDoneInfo(c, MtsOperation);

/* 201 */           log.info("[重新上架] 玩家:" + c.getPlayer().getName() + " 道具:" + mtsdoneitem.getItemid() + " 数量:" + mtsdoneitem.getQuantity() + " 价格:" + mtsdoneitem.getPrice());
/* 202 */         } catch (SQLException ex) {
/* 203 */           log.error("重新登录错误", ex);
         }
         break;

       case 下架道具:
/* 208 */         if (MTSConfig.MTS_LOWER_TIME > 0) {
/* 209 */           String mtsselltime = c.getPlayer().getKeyValue("MTS_LOWER_TIME");

/* 211 */           if (mtsselltime != null) {
/* 212 */             long diff = System.currentTimeMillis() - Long.parseLong(mtsselltime);

/* 214 */             long minute = diff / 60L / 1000L;
/* 215 */             if (minute < MTSConfig.MTS_LOWER_TIME) {
/* 216 */               c.getPlayer().dropMessage(1, "为了服务器稳定 " + MTSConfig.MTS_LOWER_TIME + "分钟后才能下架物品 上次操作时间为:" + stampToDate(mtsselltime));

               return;
             }
           }
/* 221 */           c.getPlayer().setKeyValue("MTS_LOWER_TIME", System.currentTimeMillis() + "");
         }

         try {
/* 225 */           int id = slea.readInt();

/* 227 */           MtsOperation.getItemList(c);

/* 229 */           MTSItemsInfo Selling = MtsOperation.getItemsingleNum(id);
/* 230 */           if (Selling == null) {


/* 233 */             c.announce(MTSPacket.AuctionMessage(MtsOpcode.购买道具.getValue(), MtsOpcode.道具不存在.getValue(), 0));

/* 235 */             loadSellInfo(c, MtsOperation);

             return;
           }

/* 240 */           AuctionDoneOther(c, MtsOperation.getSpItem(), MtsOperation.getQuantity(), MtsOperation.getType(), MtsOperation.getPrice(), MtsOperation.getTotalPrice(), MtsOperation.getAccid(), MtsOperation.getCid(), MtsOperation.getOwner(), 0, "", -1L, -1L, System.currentTimeMillis(), 4, MtsOperation.getQuantity(), 4);


/* 243 */           Selling.DeleteAuctionItem(Selling.getId());





/* 249 */           loadSellInfo(c, MtsOperation);

/* 251 */           loadDoneInfo(c, MtsOperation);

/* 253 */           c.announce(MTSPacket.AuctionMessage(type, 0, Selling.getId()));
/* 254 */           log.info("[下架道具] 玩家:" + c.getPlayer().getName() + " 道具:" + Selling.getItemid() + " 数量:" + Selling.getQuantity() + " 价格:" + Selling.getPrice());
/* 255 */         } catch (SQLException ex) {
/* 256 */           log.error("下架出现错误", ex);
         }
         break;


       case 购买道具:
         try {
/* 263 */           int id = slea.readInt();
/* 264 */           long price = slea.readLong();
/* 265 */           MtsOperation.getItemList(c);
/* 266 */           MTSItemsInfo mtsitem = MtsOperation.getItemsingleNum(id);
/* 267 */           if (mtsitem == null) {

/* 269 */             c.announce(MTSPacket.AuctionMessage(MtsOpcode.购买道具.getValue(), MtsOpcode.道具不存在.getValue(), 0));

             return;
           }

/* 274 */           if (c.getPlayer().getMeso() < price) {

/* 276 */             c.announce(MTSPacket.BuySuccess(type, MtsOpcode.金币不足.getValue(), mtsitem, false));

             return;
           }
/* 280 */           AuctionDoneOther(c, MtsOperation.getSpItem(), MtsOperation.getQuantity(), MtsOperation.getType(), MtsOperation.getPrice(), MtsOperation.getTotalPrice(), MtsOperation.getAccid(), MtsOperation.getCid(), MtsOperation.getOwner(), c.getPlayer().getId(), c.getPlayer().getName(), MtsOperation.getStartdate(), MtsOperation.getExpiredate(), System.currentTimeMillis(), 2, 1, 3);

/* 282 */           AuctionDoneSell(c, MtsOperation.getSpItem(), MtsOperation.getQuantity(), MtsOperation.getType(), MtsOperation.getPrice(), MtsOperation.getTotalPrice(), MtsOperation.getAccid(), MtsOperation.getCid(), MtsOperation.getOwner(), c.getPlayer().getId(), c.getPlayer().getName(), MtsOperation.getStartdate(), MtsOperation.getExpiredate(), System.currentTimeMillis(), 3, 1, 3);

/* 284 */           AuctionQuotationSave(c, MtsOperation.getSpItem(), MtsOperation.getQuantity(), MtsOperation.getType(), MtsOperation.getPrice(), MtsOperation.getTotalPrice(), MtsOperation.getCid(), MtsOperation.getOwner(), c.getPlayer().getId(), c.getPlayer().getName(), MtsOperation.getStartdate(), MtsOperation.getExpiredate(), System.currentTimeMillis());


/* 287 */           mtsitem.DeleteAuctionItem(mtsitem.getId());


/* 290 */           c.getPlayer().gainMeso(-price, false);

/* 292 */           c.announce(MTSPacket.BuySuccess(type, 0, mtsitem, false));

/* 294 */           loadSellInfo(c, MtsOperation);

/* 296 */           loadDoneInfo(c, MtsOperation);
/* 297 */           log.info("[购买道具] 玩家:" + c.getPlayer().getName() + " 道具:" + mtsitem.getItemid() + " 数量:" + mtsitem.getQuantity() + " 价格:" + price);
/* 298 */         } catch (SQLException ex) {
/* 299 */           log.error("购买拍卖单价出现错误", ex);
         }
         break;


       case 购买道具_带数量:
         try {
/* 306 */           int id = slea.readInt();

/* 308 */           long price = slea.readLong();

/* 310 */           int quantity = slea.readInt();

/* 312 */           MtsOperation.getItemList(c);
/* 313 */           MTSItemsInfo mtsitem = MtsOperation.getItemsingleNum(id);
/* 314 */           if (mtsitem == null) {

/* 316 */             c.announce(MTSPacket.AuctionMessage(MtsOpcode.购买道具.getValue(), MtsOpcode.道具不存在.getValue(), 0));

             return;
           }
/* 320 */           if (mtsitem.getQuantity() < quantity) {
/* 321 */             c.getPlayer().dropMessage(1, "购买该寄售道具数量大于该寄售道具拍卖库存数量。");
             return;
           }
/* 324 */           if (c.getPlayer().getMeso() < price) {

/* 326 */             c.announce(MTSPacket.BuySuccess(type, MtsOpcode.金币不足.getValue(), mtsitem, false));

             return;
           }

/* 331 */           AuctionDoneOther(c, MtsOperation.getSpItem(), quantity, MtsOperation.getType(), mtsitem.getPrice(), price, MtsOperation.getAccid(), MtsOperation.getCid(), MtsOperation.getOwner(), c.getPlayer().getId(), c.getPlayer().getName(), MtsOperation.getStartdate(), MtsOperation.getExpiredate(), System.currentTimeMillis(), 2, quantity, 3);

/* 333 */           AuctionDoneSell(c, MtsOperation.getSpItem(), quantity, MtsOperation.getType(), mtsitem.getPrice(), price, MtsOperation.getAccid(), MtsOperation.getCid(), MtsOperation.getOwner(), c.getPlayer().getId(), c.getPlayer().getName(), MtsOperation.getStartdate(), MtsOperation.getExpiredate(), System.currentTimeMillis(), 3, quantity, 3);

/* 335 */           AuctionQuotationSave(c, MtsOperation.getSpItem(), quantity, MtsOperation.getType(), mtsitem.getPrice(), price, MtsOperation.getCid(), MtsOperation.getOwner(), c.getPlayer().getId(), c.getPlayer().getName(), MtsOperation.getStartdate(), MtsOperation.getExpiredate(), System.currentTimeMillis());


/* 338 */           c.getPlayer().gainMeso(-price, false);

/* 340 */           long totalmeso = mtsitem.getTotalPrice() - price;
/* 341 */           if (totalmeso < 0L) {
/* 342 */             totalmeso = 0L;
           }

/* 345 */           mtsitem.UpdateItemQuantity(mtsitem.getId(), mtsitem.getPrice(), totalmeso, MtsOperation.getQuantity() - quantity);

/* 347 */           MTSItemsInfo Updatemtsitem = MtsOperation.getItemsingleNum(id);


/* 350 */           c.announce(MTSPacket.BuySuccess(MtsOpcode.更新道具数量.getValue(), 0, Updatemtsitem, false));

/* 352 */           c.announce(MTSPacket.BuySuccess(MtsOpcode.更新道具数量状态.getValue(), 0, Updatemtsitem, (Updatemtsitem.getQuantity() != 0)));
/* 353 */           c.announce(MTSPacket.AuctionMessage(type, 0, Updatemtsitem.getId()));

/* 355 */           log.info("[购买道具_多] 玩家:" + c.getPlayer().getName() + " 道具:" + mtsitem.getItemid() + " 数量:" + quantity + " 价格:" + price);
/* 356 */         } catch (SQLException ex) {
/* 357 */           log.error("购买带数量的拍卖道具出现错误", ex);
         }
         break;


       case 领取报酬:
       case 领取物品:
/* 364 */         if (MTSConfig.MTS_GET_TIME > 0) {
/* 365 */           String mtsselltime = c.getPlayer().getKeyValue("MTS_GET_TIME");

/* 367 */           if (mtsselltime != null) {
/* 368 */             long diff = System.currentTimeMillis() - Long.parseLong(mtsselltime);

/* 370 */             long minute = diff / 60L / 1000L;
/* 371 */             if (minute < MTSConfig.MTS_GET_TIME) {
/* 372 */               c.getPlayer().dropMessage(1, "为了服务器稳定 领取物品或领取报酬需要间隔" + MTSConfig.MTS_GET_TIME + "分钟 上次操作时间为:" + stampToDate(mtsselltime));
               return;
             }
           }
/* 376 */           c.getPlayer().setKeyValue("MTS_GET_TIME", System.currentTimeMillis() + "");
         }

















         try {
/* 396 */           int invid = slea.readInt();
/* 397 */           int i = slea.readInt();
/* 398 */           int sell_invid = slea.readInt();
/* 399 */           int accid = slea.readInt();
/* 400 */           int cid = slea.readInt();
/* 401 */           int itemid = slea.readInt();
/* 402 */           int j = slea.readInt();
/* 403 */           long price = slea.readLong();
/* 404 */           long donetinme = slea.readLong();
/* 405 */           long l1 = slea.readLong();
/* 406 */           int buynumber = slea.readInt();
/* 407 */           int k = slea.readInt();
/* 408 */           int unk_4 = slea.readInt();


/* 411 */           MTSItemsInfo mtsdoneitem = MtsOperation.getDoneItemsingleNum(c, invid);
/* 412 */           if (mtsdoneitem == null) {
/* 413 */             c.getPlayer().dropMessage(1, "道具不存在.请尝试退出拍卖在进入。");

             return;
           }
/* 417 */           if (mode == MtsOpcode.领取报酬) {

/* 419 */             if (c.getPlayer().getMeso() + price >= ServerConfig.CHANNEL_PLAYER_MAXMESO) {
/* 420 */               c.getPlayer().dropMessage(1, "领取失败.领取之后冒险币将超过上限.请整理下冒险币在来");

               return;
             }
/* 424 */             double aftertaxprice = price * 0.95D;

/* 426 */             c.getPlayer().gainMeso((long)aftertaxprice, false);

/* 428 */             log.info("[领取报酬] 玩家:" + c.getPlayer().getName() + " 获得报酬:" + price + "冒险币\t扣5%税后最终获得:" + (long)aftertaxprice + "冒险币");




           }
           else {




/* 439 */             if (c.getPlayer().getInventory(MapleInventoryType.getByType(mtsdoneitem.getSpItem().getType())).isFull())
             {
/* 441 */               c.announce(MTSPacket.AuctionMessage(type, MtsOpcode.背包已满.getValue(), 0));
             }


/* 445 */             MapleInventoryManipulator.addFromDrop(c, mtsdoneitem.getSpItem(), false);
/* 446 */             log.info("[领取道具] 玩家:" + c.getPlayer().getName() + " 道具:" + mtsdoneitem.getSpItem().getItemId() + " 数量:" + mtsdoneitem.getSpItem().getQuantity());
           }

/* 449 */           if (mode == MtsOpcode.领取物品 && MtsOperation.getResult() == 4) {

/* 451 */             MtsOperation.UpdateItemState(invid, 9);
           } else {
/* 453 */             MtsOperation.UpdateItemState(invid, (mode == MtsOpcode.领取报酬) ? 8 : 7);
           }

/* 456 */           c.announce(MTSPacket.AuctionMessage(type));

/* 458 */           loadSellInfo(c, MtsOperation);

/* 460 */           loadDoneInfo(c, MtsOperation);
/* 461 */         } catch (SQLException ex) {
/* 462 */           log.error("[领取物品异常]", ex);
         }
         break;

       case 首页搜索:
       case 行情搜索:
/* 468 */         if (MTSConfig.MTS_SEARCH_TIME > 0) {
/* 469 */           String mtsselltime = c.getPlayer().getKeyValue("MTS_SEARCH_TIME");

/* 471 */           if (mtsselltime != null) {
/* 472 */             long diff = System.currentTimeMillis() - Long.parseLong(mtsselltime);

/* 474 */             long second = diff / 1000L;
/* 475 */             if (second < MTSConfig.MTS_SEARCH_TIME) {
/* 476 */               c.getPlayer().dropMessage(1, "为了服务器稳定 " + MTSConfig.MTS_SEARCH_TIME + "秒后才能重新搜索 上次操作时间为:" + stampToDate(mtsselltime));

               return;
             }
           }
/* 481 */           c.getPlayer().setKeyValue("MTS_SEARCH_TIME", System.currentTimeMillis() + "");
         }
















/* 499 */         unk = slea.readByte();
/* 500 */         state = slea.readInt();
/* 501 */         ItemName = slea.readMapleAsciiString();
/* 502 */         ItemName2 = slea.readMapleAsciiString();
/* 503 */         mod_1 = slea.readInt();
/* 504 */         mod_2 = slea.readInt();
/* 505 */         level_1 = slea.readInt();
/* 506 */         level_2 = slea.readInt();
/* 507 */         price_1 = slea.readLong();
/* 508 */         price_2 = slea.readLong();
/* 509 */         unk_1 = slea.readInt();
/* 510 */         unk_2 = slea.readByte();
/* 511 */         unk_3 = slea.readInt();
/* 512 */         if (mode == MtsOpcode.行情搜索) {

/* 514 */           MtsOperation.getItemQuotation(c);

/* 516 */           MtsOperation.getItemQuotationSearch(c, state);
         } else {

/* 519 */           MtsOperation.getItemList(c);

/* 521 */           MtsOperation.getItemSearch(c, state);
         }
/* 523 */         c.announce(MTSPacket.MTSInfo(type, c, MtsOperation));
         break;


       case 出售窗口:
/* 528 */         loadSellInfo(c, MtsOperation);
         break;


       case 完成窗口:
/* 533 */         loadDoneInfo(c, MtsOperation);
         break;
     }  }







   public static void loadSellInfo(MapleClient c, MTSItemsInfo mts) {
/* 544 */     mts.getItemSell(c, c.getPlayer().getId());
/* 545 */     c.announce(MTSPacket.MTSInfo(MtsOpcode.出售窗口.getValue(), c, mts));
   }




   public static void loadDoneInfo(MapleClient c, MTSItemsInfo mts) {
/* 552 */     mts.getItemDone(c, c.getPlayer().getId());
/* 553 */     c.announce(MTSPacket.MTSDoneInfo(MtsOpcode.完成窗口.getValue(), c, mts));
   }




   public static void loadQuotationInfo(MapleClient c, MTSItemsInfo mts) {
/* 560 */     mts.getItemQuotation(c);
/* 561 */     c.announce(MTSPacket.MTSInfo(MtsOpcode.行情搜索.getValue(), c, mts));
   }




   public static void loadListInfo(MapleClient c, MTSItemsInfo mts) {
/* 568 */     mts.getItemList(c);
/* 569 */     c.announce(MTSPacket.MTSInfo(MtsOpcode.首页搜索.getValue(), c, mts));
   }




   public static void AuctionSave(MapleClient c, Item item, int quantity, int ItemType, long Price, long TotalPrice, int cid, String owner, int other_id, String other, long startdate, long expiredate, long donedate) {
/* 576 */     saveItems(c, item, quantity, ItemType, Price, TotalPrice, cid, owner, other_id, other, startdate, expiredate, donedate, 2);
   }




   public static void AuctionQuotationSave(MapleClient c, Item item, int quantity, int ItemType, long Price, long TotalPrice, int cid, String owner, int other_id, String other, long startdate, long expiredate, long donedate) {
/* 583 */     saveItems(c, item, quantity, ItemType, Price, TotalPrice, cid, owner, other_id, other, startdate, expiredate, donedate, 3);
   }




   public static void saveItems(MapleClient c, Item item, int quantity, int ItemType, long Price, long TotalPrice, int cid, String owner, int other_id, String other, long startdate, long expiredate, long donedate, int option) {
/* 590 */     PreparedStatement ps = null;
     try {
/* 592 */       int i = 1;

/* 594 */       int state = 0;
/* 595 */       if (item.getItemId() >= 1000000 && item.getItemId() <= 1999999) {
/* 596 */         if (ItemConstants.isWeapon(item.getItemId())) {
/* 597 */           state = 1;
         }

/* 600 */         if (option == 2) {
/* 601 */           ps = DatabaseConnection.getInstance().getConnection().prepareStatement("INSERT INTO auction (accid, cid, sell, other_id, other, Price,TotalPrice, startdate, expiredate, donedate, itemid, quantity, uniqueid, flag, espos, upgradeslots, level, str, dex, `int`, luk, hp, mp, watk, matk, wdef, mdef, acc, avoid, hands, speed, jump, owner, type, states, ViciousHammer, itemEXP, durability, state,enhance,potential1,potential2, potential3, addState, potential4, potential5, potential6, `incSkill`, `pvpDamage`, `charmEXP`, `statemsg`, `itemSlot1`, `itemSlot2`, `itemSlot3`, `itemSkin`, `limitBreak`, `enhanctBuff`, `reqLevel`, `yggdrasilWisdom`, `finalStrike`, `bossDamage`, `ignorePDR`, `totalDamage`, `allStat`,`karmaCount`,`fire`,`sealedlevel`,`sealedExp`,`soulname`,`soulenchanter`,`soulpotential`,`soulskill`,`arc`,`arcexp`,`arclevel`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?)");
/* 602 */         } else if (option == 3) {
/* 603 */           ps = DatabaseConnection.getInstance().getConnection().prepareStatement("INSERT INTO auction_quotation (accid, cid, sell, other_id, other, Price,TotalPrice, startdate, expiredate, donedate, itemid, quantity, uniqueid, flag, espos, upgradeslots, level, str, dex, `int`, luk, hp, mp, watk, matk, wdef, mdef, acc, avoid, hands, speed, jump, owner, type, states, ViciousHammer, itemEXP, durability, state,enhance,potential1,potential2, potential3, addState, potential4, potential5, potential6, `incSkill`, `pvpDamage`, `charmEXP`, `statemsg`, `itemSlot1`, `itemSlot2`, `itemSlot3`, `itemSkin`, `limitBreak`, `enhanctBuff`, `reqLevel`, `yggdrasilWisdom`, `finalStrike`, `bossDamage`, `ignorePDR`, `totalDamage`, `allStat`,`karmaCount`,`fire`,`sealedlevel`,`sealedExp`,`soulname`,`soulenchanter`,`soulpotential`,`soulskill`,`arc`,`arcexp`,`arclevel`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?)");
         } else {
           return;
         }
/* 607 */         Equip eq = (Equip)item;
/* 608 */         ps.setInt(++i, cid);
/* 609 */         ps.setString(++i, owner);
/* 610 */         ps.setInt(++i, other_id);
/* 611 */         ps.setString(++i, other);
/* 612 */         ps.setLong(++i, Price);
/* 613 */         ps.setLong(++i, TotalPrice);
/* 614 */         ps.setLong(++i, startdate);
/* 615 */         ps.setLong(++i, expiredate);
/* 616 */         ps.setLong(++i, donedate);
/* 617 */         ps.setInt(++i, eq.getItemId());
/* 618 */         ps.setInt(++i, 1);
/* 619 */         ps.setInt(++i, eq.getUniqueId());
/* 620 */         ps.setInt(++i, eq.getFlag());
/* 621 */         ps.setInt(++i, eq.getESPos());
/* 622 */         ps.setInt(++i, eq.getUpgradeSlots());
/* 623 */         ps.setInt(++i, eq.getLevel());
/* 624 */         ps.setInt(++i, eq.getStr());
/* 625 */         ps.setInt(++i, eq.getDex());
/* 626 */         ps.setInt(++i, eq.getInt());
/* 627 */         ps.setInt(++i, eq.getLuk());
/* 628 */         ps.setInt(++i, eq.getHp());
/* 629 */         ps.setInt(++i, eq.getMp());
/* 630 */         ps.setInt(++i, eq.getWatk());
/* 631 */         ps.setInt(++i, eq.getMatk());
/* 632 */         ps.setInt(++i, eq.getWdef());
/* 633 */         ps.setInt(++i, eq.getMdef());
/* 634 */         ps.setInt(++i, eq.getAcc());
/* 635 */         ps.setInt(++i, eq.getAvoid());
/* 636 */         ps.setInt(++i, eq.getHands());
/* 637 */         ps.setInt(++i, eq.getSpeed());
/* 638 */         ps.setInt(++i, eq.getJump());
/* 639 */         ps.setString(++i, eq.getOwner());
/* 640 */         ps.setInt(++i, 1);
/* 641 */         ps.setInt(++i, state);
/* 642 */         ps.setInt(++i, eq.getViciousHammer());
/* 643 */         ps.setLong(++i, eq.getItemEXP());
/* 644 */         ps.setInt(++i, eq.getDurability());
/* 645 */         ps.setInt(++i, eq.getState(false));
/* 646 */         ps.setInt(++i, eq.getEnhance());
/* 647 */         ps.setInt(++i, eq.getPotential1());
/* 648 */         ps.setInt(++i, eq.getPotential2());
/* 649 */         ps.setInt(++i, eq.getPotential3());
/* 650 */         ps.setInt(++i, eq.getState(true));
/* 651 */         ps.setInt(++i, eq.getPotential4());
/* 652 */         ps.setLong(++i, eq.getPotential5());
/* 653 */         ps.setInt(++i, eq.getPotential6());
/* 654 */         ps.setInt(++i, eq.getIncSkill());
/* 655 */         ps.setInt(++i, eq.getPVPDamage());
/* 656 */         ps.setInt(++i, eq.getCharmEXP());
/* 657 */         ps.setInt(++i, eq.getStateMsg());
/* 658 */         ps.setInt(++i, eq.getSocket1());
/* 659 */         ps.setInt(++i, eq.getSocket2());
/* 660 */         ps.setInt(++i, eq.getSocket3());
/* 661 */         ps.setInt(++i, eq.getItemSkin());
/* 662 */         ps.setLong(++i, eq.getLimitBreak());
/* 663 */         ps.setInt(++i, eq.getEnhanctBuff());
/* 664 */         ps.setInt(++i, eq.getReqLevel());
/* 665 */         ps.setInt(++i, eq.getYggdrasilWisdom());
/* 666 */         ps.setBoolean(++i, eq.getFinalStrike());
/* 667 */         ps.setInt(++i, eq.getBossDamage());
/* 668 */         ps.setInt(++i, eq.getIgnorePDR());
/* 669 */         ps.setInt(++i, eq.getTotalDamage());
/* 670 */         ps.setInt(++i, eq.getAllStat());
/* 671 */         ps.setInt(++i, eq.getKarmaCount());
/* 672 */         ps.setLong(++i, eq.getFire());
/* 673 */         ps.setInt(++i, eq.getSealedLevel());
/* 674 */         ps.setLong(++i, eq.getSealedExp());
/* 675 */         ps.setInt(++i, eq.getSoulName());
/* 676 */         ps.setInt(++i, eq.getSoulEnchanter());
/* 677 */         ps.setInt(++i, eq.getSoulPotential());
/* 678 */         ps.setInt(++i, eq.getSoulSkill());
/* 679 */         ps.setInt(++i, eq.getARC());
/* 680 */         ps.setInt(++i, eq.getARCExp());
/* 681 */         ps.setInt(++i, eq.getARCLevel());
       } else {
/* 683 */         if (item.getItemId() >= 2000000 && item.getItemId() <= 2999999) {
/* 684 */           state = 2;
/* 685 */         } else if (item.getItemId() >= 5000000 && item.getItemId() <= 5999999) {
/* 686 */           state = 3;
/* 687 */         } else if (item.getItemId() >= 3000000 && item.getItemId() <= 4999999) {
/* 688 */           state = 4;
         }
/* 690 */         if (option == 2) {
/* 691 */           ps = DatabaseConnection.getInstance().getConnection().prepareStatement("INSERT INTO auction (accid, cid, sell, other_id, other, Price,TotalPrice, startdate, expiredate, donedate, itemid, quantity, itemowner, type, states, itemexpiredate, sender) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?)");
/* 692 */         } else if (option == 3) {
/* 693 */           ps = DatabaseConnection.getInstance().getConnection().prepareStatement("INSERT INTO auction_quotation (accid, cid, sell, other_id, other, Price,TotalPrice, startdate, expiredate, donedate, itemid, quantity, itemowner, type, states, itemexpiredate, sender) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?)");
         } else {
           return;
         }
/* 697 */         ps.setInt(++i, cid);
/* 698 */         ps.setString(++i, owner);
/* 699 */         ps.setInt(++i, other_id);
/* 700 */         ps.setString(++i, other);
/* 701 */         ps.setLong(++i, Price);
/* 702 */         ps.setLong(++i, TotalPrice);
/* 703 */         ps.setLong(++i, startdate);
/* 704 */         ps.setLong(++i, expiredate);
/* 705 */         ps.setLong(++i, donedate);
/* 706 */         ps.setInt(++i, item.getItemId());
/* 707 */         ps.setInt(++i, quantity);
/* 708 */         ps.setString(++i, item.getOwner());
/* 709 */         ps.setInt(++i, ItemType);
/* 710 */         ps.setInt(++i, state);
/* 711 */         ps.setLong(++i, item.getExpiration());
/* 712 */         ps.setString(++i, item.getGiftFrom());
       }
/* 714 */       ps.setInt(1, c.getAccID());
/* 715 */       ps.executeUpdate();
/* 716 */       ps.close();
     }
/* 718 */     catch (SQLException ex) {
/* 719 */       log.error("从背包保存到数据库出错", ex);
     } finally {
       try {
/* 722 */         if (ps != null) {
/* 723 */           ps.close();
         }
/* 725 */       } catch (SQLException sQLException) {}
     }
   }





   public static void AuctionDoneOther(MapleClient c, Item item, int quantity, int ItemType, long Price, long TotalPrice, int sell_accid, int sell_cid, String sell_name, int other_id, String other, long startdate, long expiredate, long donedate, int states, int buynumber, int result) {
/* 734 */     SaveItemDone(c, item, quantity, ItemType, Price, TotalPrice, sell_accid, sell_cid, sell_name, other_id, other, startdate, expiredate, donedate, states, buynumber, result, false);
   }




   public static void AuctionDoneSell(MapleClient c, Item item, int quantity, int ItemType, long Price, long TotalPrice, int sell_accid, int sell_cid, String sell_name, int other_id, String other, long startdate, long expiredate, long donedate, int states, int buynumber, int result) {
/* 741 */     SaveItemDone(c, item, quantity, ItemType, Price, TotalPrice, sell_accid, sell_cid, sell_name, other_id, other, startdate, expiredate, donedate, states, buynumber, result, true);
   }

   public static void SaveItemDone(MapleClient c, Item item, int quantity, int ItemType, long Price, long TotalPrice, int sell_accid, int sell_cid, String sell_name, int other_id, String other, long startdate, long expiredate, long donedate, int states, int buynumber, int result, boolean sell) {
/* 745 */     PreparedStatement ps = null;
     try {
/* 747 */       int i = 1;
/* 748 */       if (item.getItemId() >= 1000000 && item.getItemId() <= 1999999) {
/* 749 */         ps = DatabaseConnection.getInstance().getConnection().prepareStatement("INSERT INTO auction_done (character_id, sell_accid, sell_cid, sell_name, other_id, other_name, Price,TotalPrice, startdate, expiredate, donedate, itemid, quantity, uniqueid, flag, espos, upgradeslots, level, str, dex, `int`, luk, hp, mp, watk, matk, wdef, mdef, acc, avoid, hands, speed, jump, owner, type, states, buynumber, result, ViciousHammer, itemEXP, durability, state,enhance,potential1,potential2, potential3, addState, potential4, potential5, potential6, `incSkill`, `pvpDamage`, `charmEXP`, `statemsg`, `itemSlot1`, `itemSlot2`, `itemSlot3`, `itemSkin`, `limitBreak`, `enhanctBuff`, `reqLevel`, `yggdrasilWisdom`, `finalStrike`, `bossDamage`, `ignorePDR`, `totalDamage`, `allStat`,`karmaCount`,`fire`,`sealedlevel`,`sealedExp`,`soulname`,`soulenchanter`,`soulpotential`,`soulskill`,`arc`,`arcexp`,`arclevel`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?)");
/* 750 */         Equip eq = (Equip)item;
/* 751 */         ps.setInt(++i, sell_accid);
/* 752 */         ps.setInt(++i, sell_cid);
/* 753 */         ps.setString(++i, sell_name);
/* 754 */         ps.setInt(++i, other_id);
/* 755 */         ps.setString(++i, other);
/* 756 */         ps.setLong(++i, Price);
/* 757 */         ps.setLong(++i, TotalPrice);
/* 758 */         ps.setLong(++i, startdate);
/* 759 */         ps.setLong(++i, expiredate);
/* 760 */         ps.setLong(++i, donedate);
/* 761 */         ps.setInt(++i, eq.getItemId());
/* 762 */         ps.setInt(++i, 1);
/* 763 */         ps.setInt(++i, eq.getUniqueId());
/* 764 */         ps.setInt(++i, eq.getFlag());
/* 765 */         ps.setInt(++i, eq.getESPos());
/* 766 */         ps.setInt(++i, eq.getUpgradeSlots());
/* 767 */         ps.setInt(++i, eq.getLevel());
/* 768 */         ps.setInt(++i, eq.getStr());
/* 769 */         ps.setInt(++i, eq.getDex());
/* 770 */         ps.setInt(++i, eq.getInt());
/* 771 */         ps.setInt(++i, eq.getLuk());
/* 772 */         ps.setInt(++i, eq.getHp());
/* 773 */         ps.setInt(++i, eq.getMp());
/* 774 */         ps.setInt(++i, eq.getWatk());
/* 775 */         ps.setInt(++i, eq.getMatk());
/* 776 */         ps.setInt(++i, eq.getWdef());
/* 777 */         ps.setInt(++i, eq.getMdef());
/* 778 */         ps.setInt(++i, eq.getAcc());
/* 779 */         ps.setInt(++i, eq.getAvoid());
/* 780 */         ps.setInt(++i, eq.getHands());
/* 781 */         ps.setInt(++i, eq.getSpeed());
/* 782 */         ps.setInt(++i, eq.getJump());
/* 783 */         ps.setString(++i, eq.getOwner());
/* 784 */         ps.setInt(++i, 1);
/* 785 */         ps.setInt(++i, states);
/* 786 */         ps.setInt(++i, 1);
/* 787 */         ps.setInt(++i, result);
/* 788 */         ps.setInt(++i, eq.getViciousHammer());
/* 789 */         ps.setLong(++i, eq.getItemEXP());
/* 790 */         ps.setInt(++i, eq.getDurability());
/* 791 */         ps.setInt(++i, eq.getState(false));
/* 792 */         ps.setInt(++i, eq.getEnhance());
/* 793 */         ps.setInt(++i, eq.getPotential1());
/* 794 */         ps.setInt(++i, eq.getPotential2());
/* 795 */         ps.setInt(++i, eq.getPotential3());
/* 796 */         ps.setInt(++i, eq.getState(true));
/* 797 */         ps.setInt(++i, eq.getPotential4());
/* 798 */         ps.setInt(++i, eq.getPotential5());
/* 799 */         ps.setInt(++i, eq.getPotential6());
/* 800 */         ps.setInt(++i, eq.getIncSkill());
/* 801 */         ps.setInt(++i, eq.getPVPDamage());
/* 802 */         ps.setInt(++i, eq.getCharmEXP());
/* 803 */         ps.setInt(++i, eq.getStateMsg());
/* 804 */         ps.setInt(++i, eq.getSocket1());
/* 805 */         ps.setInt(++i, eq.getSocket2());
/* 806 */         ps.setInt(++i, eq.getSocket3());
/* 807 */         ps.setInt(++i, eq.getItemSkin());
/* 808 */         ps.setLong(++i, eq.getLimitBreak());
/* 809 */         ps.setInt(++i, eq.getEnhanctBuff());
/* 810 */         ps.setInt(++i, eq.getReqLevel());
/* 811 */         ps.setInt(++i, eq.getYggdrasilWisdom());
/* 812 */         ps.setBoolean(++i, eq.getFinalStrike());
/* 813 */         ps.setInt(++i, eq.getBossDamage());
/* 814 */         ps.setInt(++i, eq.getIgnorePDR());
/* 815 */         ps.setInt(++i, eq.getTotalDamage());
/* 816 */         ps.setInt(++i, eq.getAllStat());
/* 817 */         ps.setInt(++i, eq.getKarmaCount());
/* 818 */         ps.setLong(++i, eq.getFire());
/* 819 */         ps.setInt(++i, eq.getSealedLevel());
/* 820 */         ps.setLong(++i, eq.getSealedExp());
/* 821 */         ps.setInt(++i, eq.getSoulName());
/* 822 */         ps.setInt(++i, eq.getSoulEnchanter());
/* 823 */         ps.setInt(++i, eq.getSoulPotential());
/* 824 */         ps.setInt(++i, eq.getSoulSkill());
/* 825 */         ps.setInt(++i, eq.getARC());
/* 826 */         ps.setInt(++i, eq.getARCExp());
/* 827 */         ps.setInt(++i, eq.getARCLevel());
       } else {
/* 829 */         ps = DatabaseConnection.getInstance().getConnection().prepareStatement("INSERT INTO auction_done (character_id, sell_accid, sell_cid, sell_name, other_id, other_name, Price,TotalPrice, startdate, expiredate, donedate, itemid, quantity, itemowner, type, states, buynumber, result, itemexpiredate, sender) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?)");
/* 830 */         ps.setInt(++i, sell_accid);
/* 831 */         ps.setInt(++i, sell_cid);
/* 832 */         ps.setString(++i, sell_name);
/* 833 */         ps.setInt(++i, other_id);
/* 834 */         ps.setString(++i, other);
/* 835 */         ps.setLong(++i, Price);
/* 836 */         ps.setLong(++i, TotalPrice);
/* 837 */         ps.setLong(++i, startdate);
/* 838 */         ps.setLong(++i, expiredate);
/* 839 */         ps.setLong(++i, donedate);
/* 840 */         ps.setInt(++i, item.getItemId());
/* 841 */         ps.setInt(++i, quantity);
/* 842 */         ps.setString(++i, item.getOwner());
/* 843 */         ps.setInt(++i, ItemType);
/* 844 */         ps.setInt(++i, states);
/* 845 */         ps.setInt(++i, buynumber);
/* 846 */         ps.setInt(++i, result);
/* 847 */         ps.setLong(++i, item.getExpiration());
/* 848 */         ps.setString(++i, item.getGiftFrom());
       }
/* 850 */       ps.setInt(1, sell ? sell_cid : c.getPlayer().getId());
/* 851 */       ps.executeUpdate();
/* 852 */       ps.close();
     }
/* 854 */     catch (SQLException ex) {
/* 855 */       log.error("保存道具到完成窗口错误", ex);
     } finally {
       try {
/* 858 */         if (ps != null) {
/* 859 */           ps.close();
         }
/* 861 */       } catch (SQLException sQLException) {}
     }
   }






   public static String stampToDate(String s) {
/* 871 */     SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm:ss");
/* 872 */     long lt = (new Long(s)).longValue();
/* 873 */     Date date = new Date(lt);
/* 874 */     String res = simpleDateFormat.format(date);
/* 875 */     return res;
   }
 }


/* Location:              C:\PGX\Server.jar!\handling\cashshop\handler\MTSOperation.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */